def is_happy(n):
    for _ in range(20):
        b = 0
        while n > 0:
            a = n % 10
            b = b + a * a
            n = n // 10
        if b == 1:
            return True
        n = b
    return False
print(is_happy(32))